@model BackgroundTaskViewModel

<h1>@RenderTitleSegments(T["Edit Task Settings"])</h1>

<div asp-validation-summary="ModelOnly"></div>
<form asp-action="Edit" method="post">

    <div class="form-group" asp-validation-class-for="Name">
        <label asp-for="Name">@T["Name"]</label>
        <input asp-for="Name" class="form-control" readonly />
        <span class="hint">@T["The task on which this settings will apply."]</span>
    </div>

    <div class="form-group" asp-validation-class-for="Schedule">
        <label asp-for="Schedule">@T["Schedule"]</label>
        <input asp-for="Schedule" class="form-control" autofocus />
        <span class="hint">@T["The task schedule as a cron expression."]</span>
    </div>

    <div class="form-group" asp-validation-class-for="Description">
        <input asp-for="Enable" class="form-control" type="hidden" />
        <input asp-for="DefaultSchedule" class="form-control" type="hidden" />
        <input asp-for="Description" class="form-control" type="hidden" />
    </div>

    <div class="form-group">
        <button id="use-default-schedule" class="btn btn-success">@T["Use Default"]</button>
        <button class="btn btn-primary" type="submit">@T["Save"]</button>
        <a class="btn btn-secondary" asp-route-action="Index">@T["Cancel"]</a>
    </div>
</form>

<script at="Foot">
$(function () {
    $('#use-default-schedule').on('click', function (e) {
        e.preventDefault();
        document.getElementById('@Html.IdFor(x => x.Schedule)').value =
            document.getElementById('@Html.IdFor(x => x.DefaultSchedule)').value;
    });
});
</script>
